package org.msd.controller;

import org.apache.ibatis.annotations.Param;
import org.msd.model.UserInfo;
import org.msd.service.iml.PerohSerice;
import org.msd.service.iml.Registered;
import org.msd.service.iml.UserinforServiceimp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/usre")
public class Usercontrller {
    @Autowired
    private UserinforServiceimp userinforServiceimp;//个人信息查询
    @Autowired
     private PerohSerice perohSerice;
    @Autowired
    private Registered registered;
    @RequestMapping("/infor")
    @ResponseBody
    public List<UserInfo> Displaypersonalinformation(UserInfo userInfo){

       //传递过来是空就是查询所有 不是就是搜索功能
        List<UserInfo>    userInfos=userinforServiceimp.Querypersonalin();//查询所有

        return  userInfos;
    }
    @RequestMapping("increase")
    @ResponseBody
    public String  personalprivacy(String name,String password,String cellphonenumber,String realname,String identification,String location){

    int   p=perohSerice.thrustinformation(name, realname, identification, location);
   int       p1=registered.Insertuser(name, password, cellphonenumber);
    if (p==1&&p1==1){
       return "插入成功";
   }else {

   }
        return null;
    }
    /*
    删除一对一
     */

   @RequestMapping("deletename")
    @ResponseBody
    public String Deleteamessage(@RequestParam("name")String name){
    int per=perohSerice.DeleteMessage(name);
    int reg=registered.Deletelogininformation(name);
    if (per==1&&reg==1){
      return "删除成功";
     }else {

    }
        return null;
     }
}
